﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WSLuuDiemV2
{
    
    public class ServiceLuuDiem : IServiceLuuDiem
    {
        public IList<KetQua> GetData()
        {
            QuanLyDiem ql = new QuanLyDiem();
            return ql.LoadFile();
        }

        public void SetData(KetQua kq)
        {
            QuanLyDiem ql = new QuanLyDiem();
            List<KetQua> ds = ql.LoadFile();
            if (ds == null)
                ds = new List<KetQua>();
            ds.Add(kq);
            List<KetQua> dsMoi = ds.OrderByDescending(x => x.Diem).Take(5).ToList();
            ql.SaveFile(dsMoi);
        }


        public IList<KetQua> LayDuLieu()
        {
            QuanLyDiem ql = new QuanLyDiem();
            return ql.LoadFile();
        }
    }
}
